<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        #div1 {
            width: 300px;
            height: 300px;
            background: yellowgreen;
        }
        
        #div2 {
            width: 100px;
            height: 100px;
            background: red;
            position: absolute;
        }
    </style>
</head>

<body>
    <div id="puter">
        <div id="div1"></div>
        <div id="div2"></div>
    </div>



    <script>
        document.onmousemove = function(event) {
            event = event || window.event;
            let st = document.documentElement.scrollTop || document.body.scrollTop;
            let sl = document.documentElement.scrollLeft || document.body.scrollLeft;

            let x = event.clientX;
            let y = event.clientY;

            div2.style.left = sl + x + "px";
            div2.style.top = st + y + "px";

        }



        div1.onmousemove = function(event) {
            event = event || window.event;
            event.cancelBubble = true;
        }
    </script>
</body>

</html>